﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Model.WorkFlow;
using Enterprise.Service.WorkFlow;
using Enterprise.Infrastructure;
using Enterprise.Control;
namespace Enterprise.UI.Web.Manage.WorkFlow
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        private void OnStart()
        {
            CreateBT.AddButton("Manage.aspx?Cmd=New", Utility.PopedomType.New, HeadMenuWebControls1);
            OnBindData();
        }
        private void OnBindData()
        {
            WorkFlowInfoService ser = new WorkFlowInfoService();
            var q = ser.WorkFlowList();
            GridView1.DataSource = q;
            GridView1.DataBind();
        }

        protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onMouseOver"] = "js.ItemOver(this)";
            }
        }

        protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt32(e.CommandArgument); //获取行号
            int did = (int)GridView1.DataKeys[index].Value;
            WorkFlowInfoService ser = new WorkFlowInfoService();
            var q = ser.WorkFlowDisp(did);
            if (q != null)
            {
                switch (e.CommandName)
                {
                    case "mDelete":
                        q.DB_Option_Action = "Delete";
                        ser.WorkFlowExecute(q);
                        break;
                }
                OnStart();
            }
        }
    }
}